package pansky.math;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

/**
 * Created by Adi（adi@imeth.cn） on 2016/11/3.
 */

public class MathModule extends ReactContextBaseJavaModule {

    public MathModule(ReactApplicationContext reactContext) {
        super(reactContext);
    }

    @Override
    public String getName() {
        return "Math";
    }

    @ReactMethod
    public void add(int a, int b, Promise promise) {
        promise.resolve(a+b);
    }

    @ReactMethod
    public void multiply(int a, int b, Callback callback) {
        callback.invoke(a * b);
    }

}
